import { Resolver, Query, Args } from '@nestjs/graphql';
import { ModelService } from './model.service';

@Resolver('Model')
export class ModelResolver {

  constructor(private readonly modelService: ModelService) {}

  @Query('model')
  async getBlock(@Args('id') id: number) {
    return this.modelService.findOneById(id);
  }

  @Query('models')
  async getBlocks(@Args() args: { page: number, pageSize: number }) {
    const { page = 1, pageSize = 20 } = args;
    const result = this.modelService.findWithPagination(page, pageSize);
    return result;
  }
}
